import http from '@/util/http'
import qs from 'qs'

export function wallpaperById (id) {
  return http.get(`/wallpaper?id=${id}`)
}

export function wallpaperList (search, current, pageSize) {
  return http.post(`/wallpaper/get?pageNo=${current}&pageSize=${pageSize}`, search)
}

export function wallpaperGetImage (wallpaperLibId) {
  return http.get(`/wallpaper/getImage?wallpaperLibId=${wallpaperLibId}`)
}

export function addWallpaper (data) {
  return http.post('/wallpaper', data)
}

export function updateWallpaper (data) {
  return http.put('/wallpaper', data)
}

export function delWallpaper (id) {
  return http.delete(`/wallpaper?id=${id}`)
}

export function wallpaperAddImage (wallpaperLibId, imageIds) {
  return http.post('/wallpaper/addImage', qs.stringify({ wallpaperLibId: wallpaperLibId, imageIds: imageIds }, { arrayFormat: 'repeat' }))
}

export function wallpaperDelImage (id) {
  return http.delete(`/wallpaper/delImage?id=${id}`)
}
